<?php echo $this->Html->script('telefone'); ?>
<fieldset  style="border: 1px solid #c5c5c5;">
    <legend>Telefone(s)</legend>
    <table width="100%" id="tbTelefones">
        <tr>
            <th>
                <?php echo $this->Form->input('Tipo', array('type' => 'select', 'label' => 'Tipo', 'id' => 'selTipoFone', 'class' => 'box100', 'options' => array('R' => 'Residencia', 'C' => 'Celular', 'F' => 'Fax', 'T' => 'Trabalho', 'O' => 'Outros',))); ?>
            </th>
            <th width="15%">
                <?php echo $this->Form->input('DDD', array('type' => 'text', 'label' => 'DDD', 'id' => 'txtDDD', 'class' => 'campoNumerico', 'size' => "3", 'maxlength' => "2")); ?>
            </th>
            <th>
                <?php echo $this->Form->input('Telefone', array('type' => 'tel', 'label' => 'Telefone', 'id' => 'txtFone', 'class' => 'campoTelefone', 'size' => "15", 'maxlength' => "10")); ?>
            </th>
            <th>
                <?php echo $this->Html->image('/img/incluir.png', array('id' => 'btnAdicionar', 'onclick' => 'Adicionar();')) ?>
            </th>
        </tr>
        <tbody id="listaFones">
            <?php
            $telefones = $this->request->data('TELEFONES');
            ?>
            <?php
            if (isset($telefones)):
                $index = 0;
                $usuarios = $this->Session->read('usuario');
                foreach ($telefones as $fone):

                    ?>
                    <tr>
                        <td>
                            <?php echo $this->Form->input('', array('type' => 'hidden', 'label' => false, 'value' => $fone['CO_TELEFONE'])) ?>
                            <?php echo $this->Form->input('', array('type' => 'hidden', 'label' => false, 'value' => $fone['TP_TELEFONE'])) ?>
                            <?php //echo $this->Form->input('Telefone.' . $index . '.ST_PRINCIPAL', array('type' => 'hidden', 'label' => false, 'value' => $fone['ST_PRINCIPAL'])) ?>
                            <?php echo $this->Form->input('', array('type' => 'radio', 'label' => false, 'options' => array('S'=>''), 'checked' => (($fone['ST_PRINCIPAL'] === 'S') ? true : false) )) ?>
                            <?php echo $this->Siscel->tipoTelefone($fone['TP_TELEFONE']); ?>
                        </td>
                        <td>
                            <?php echo $this->Form->input('', array('type' => 'hidden', 'label' => false, 'value' => $fone['DDD_TELEFONE'])) ?><?php echo $fone['DDD_TELEFONE']; ?>
                        </td>
                        <td>
                            <?php echo $this->Form->input('', array('type' => 'hidden', 'label' => false, 'value' => $fone['NU_TELEFONE'])) ?><?php echo $fone['NU_TELEFONE']; ?>
                        </td>
                        <td>
                            <img src='/siscel/img/bt_apagar.gif'  id='btnExcluir<?php echo $index ?>' class='btnExcluir' onclick="deletarTelefone(<?php echo $fone['CO_TELEFONE'] ?>, this)"/>
                        </td>
                    </tr>
                    <?php
                    $index++;
                endforeach;
            endif;
            ?>
        </tbody>
    </table>
</fieldset>
<script language="javascript">
    function Excluir(idImg) {
        var par = $('#' + idImg).parent().parent(); //tr
        par.remove();
    }
    ;
</script>